package com.liming.mail.controller;

import cn.hutool.core.io.FileUtil;
import cn.hutool.extra.mail.MailUtil;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.concurrent.CompletableFuture;

/**
 * @author liming
 * @date 2025/5/22
 */
@Slf4j
@RestController
@AllArgsConstructor
@Tag(name = "邮件-Service")
@RequestMapping("/service/mail")
public class MailController {

    @PostMapping(value = "send_mail")
    public String qqSendMail() {
        for (int i = 0; i < 5; i++) {
            CompletableFuture.runAsync(() -> MailUtil.send("326216134@qq.com;2271905957@qq.com;2718804895@qq.com;273230463@qq.com;1962105263@qq.com", "爱你", "爱你爱你", false, FileUtil.file("C:\\Users\\liming\\Desktop\\test.txt")));
        }
        return "发送邮件成功";
    }
}
